package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.LocationClass;
import cn.wolfcode.crm.mapper.LocationClassMapper;
import cn.wolfcode.crm.query.LocationClassQueryObject;
import cn.wolfcode.crm.service.ILocationClassService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class LocationClassServiceImpl implements ILocationClassService {
    @Autowired
    private LocationClassMapper locationClassMapper;


    public void deleteByPrimaryKey(Long id) {

        locationClassMapper.deleteByPrimaryKey(id);
    }

    public void insert(LocationClass record) {

        locationClassMapper.insert(record);
    }

    public LocationClass selectByPrimaryKey(Long id) {

        return locationClassMapper.selectByPrimaryKey(id);
    }

    public List<LocationClass> selectAll() {

        return locationClassMapper.selectAll();
    }

    public void updateByPrimaryKey(LocationClass record) {
        locationClassMapper.updateByPrimaryKey(record);
    }

    public PageResult query(LocationClassQueryObject qo) {
        int total = locationClassMapper.query4Count(qo);
        if (total > 0) {
            return new PageResult(total, locationClassMapper.query4List(qo));
        }
        return new PageResult(total, Collections.EMPTY_LIST);
    }

    public void changState(Long id) {
        locationClassMapper.changState(id);
    }
}
